package com.fansl.allround.upms.api.feign;

import com.fansl.allround.common.core.bean.UserInfo;
import com.fansl.allround.common.core.constant.SecurityConstants;
import com.fansl.allround.common.core.constant.ServiceNameConstants;
import com.fansl.allround.common.core.constant.enums.OauthTypeEnum;
import com.fansl.allround.upms.api.dto.BindSocialInfoDTO;
import com.fansl.allround.upms.api.dto.SysSocialUserDTO;
import com.fansl.allround.upms.api.dto.UnbindSocialInfoDTO;
import com.fansl.allround.upms.api.feign.factory.RemoteUserServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author fansl
 * @Description: TODO
 * @date 2019/8/9 16:23
 */
@FeignClient(contextId = "remoteUserService",value = ServiceNameConstants.UMPS_SERVICE,fallbackFactory = RemoteUserServiceFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户、角色信息
     *
     * @param username 用户名
     * @param from     调用标志
     * @return R
     */
    @GetMapping("/user/info/{username}")
    UserInfo info(@PathVariable("username") String username
            , @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 通过社交账号查询用户、角色信息
     *
     * @param openid
     * @param oauthType 认证类型
     * @param from 调用标志
     * @return
     */
    @GetMapping("/inner/user/social/info/{openid}")
    UserInfo social(@PathVariable("openid") String openid,
                    @RequestParam("oauthType")OauthTypeEnum oauthType,
                    @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 通过手机号查询用户、角色信息
     *
     * @param mobile 手机号
     * @param from   调用标志
     * @return R
     */
    @GetMapping("/inner/user/mobile/{mobile}")
    UserInfo mobile(@PathVariable("mobile") String mobile
            ,@RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 注册社交用户
     * @param socialUser
     * @param from 调用标志
     * @return
     */
    @PostMapping("/inner/user/social/create")
    UserInfo createSocialUser(SysSocialUserDTO socialUser,
                              @RequestHeader(SecurityConstants.FROM)String from);

    /**
     * 绑定第三方应用
     * @param socialInfo
     * @return
     */
    @PostMapping("/inner/user/social/bind")
    Boolean bindSocialInfo(@RequestBody BindSocialInfoDTO socialInfo,
                           @RequestHeader(SecurityConstants.FROM)String from);

    /**
     * 解绑第三方应用
     * @param socialInfo
     * @return
     */
    @PostMapping("/inner/user/social/unbind")
    Boolean unbindSocialInfo(@RequestBody UnbindSocialInfoDTO socialInfo,
                             @RequestHeader(SecurityConstants.FROM)String from);
}
